#include <iostream>
using namespace std;

string generate_salutation(string generic1, string lastname, 
							string generic2, string::size_type pos,
							int length){
	return generic1.replace(generic1.find("Daisy", 0), 5, lastname).
					replace(generic1.find("Ms", 0), 2, generic2.substr(pos, length));
}

int main() {
	string generic1("Dear Ms Daisy:");
	string generic2("MrsMsMissPeople");
	
	string lastname("AnnaP");
	string greetings = 
		generate_salutation(generic1, lastname, generic2, 5, 4);
	cout << greetings << endl;
}
